package com.moxiao.yfjh.module.blind.dal.mysql.commonphrases;

import com.moxiao.yfjh.module.blind.controller.admin.commonphrases.vo.CommonPhrasesExportReqVO;
import com.moxiao.yfjh.module.blind.controller.admin.commonphrases.vo.CommonPhrasesPageReqVO;
import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.blind.dal.dataobject.commonphrases.CommonPhrasesDO;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.blind.controller.admin.commonphrases.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 相亲会员常用语 Mapper
 *
 * @author mx
 */
@Mapper
public interface CommonPhrasesMapper extends BaseMapperX<CommonPhrasesDO> {

    default PageResult<CommonPhrasesDO> selectPage(CommonPhrasesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CommonPhrasesDO>()
                .eqIfPresent(CommonPhrasesDO::getLevelId, reqVO.getLevelId())
                .eqIfPresent(CommonPhrasesDO::getCommonPhrases, reqVO.getCommonPhrases())
                .eqIfPresent(CommonPhrasesDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CommonPhrasesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CommonPhrasesDO::getId));
    }

    default List<CommonPhrasesDO> selectList(CommonPhrasesExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CommonPhrasesDO>()
                .eqIfPresent(CommonPhrasesDO::getLevelId, reqVO.getLevelId())
                .eqIfPresent(CommonPhrasesDO::getCommonPhrases, reqVO.getCommonPhrases())
                .eqIfPresent(CommonPhrasesDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CommonPhrasesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CommonPhrasesDO::getId));
    }

    @Select("select count(*) num from blind_common_phrases where no = #{commonPhrasesNo}")
    Integer getCommonPhrasesNo(@Param("commonPhrasesNo") String commonPhrasesNo);

}
